package com.csx.governance.traffic.condition;

import java.util.Objects;

/**
 * @author cuisongxu
 * @date 2023/2/25 11:23
 */
public class ParsedExpression {

    private final Object expression;

    public ParsedExpression(Object expression) {
        Objects.requireNonNull(expression, "expression cannot be null");
        this.expression = expression;
    }

    public <T> T getExpression(Class<T> desiredResultType) {
        if(desiredResultType == null) {
            return null;
        }

        if(desiredResultType.isInstance(expression)) {
            return desiredResultType.cast(expression);
        }

        return null;
    }
}
